package com.levy.contronller.javaWeb.threadConcurrence.threadApiTest;

import java.util.concurrent.TimeUnit;

/**
 * Created by levy on 2019/7/9.
 */
public class TestMain2 extends Thread{

    private boolean isRun = true;

    public void setRun(boolean run) {
        isRun = run;
    }

    @Override
    public void run() {

        System.out.println("enter run……");

        while (isRun){
            //

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            setRun(false);
        }
        System.out.println("run stop");
    }

    public static void main(String[] args) throws InterruptedException {
        TestMain2 t = new TestMain2();
        t.start();

        Thread.sleep(2000);

//        t.setRun(false);

        System.out.println("set run over");


        TimeUnit.SECONDS.sleep(2);
    }
}
